package cc.liyinghao.common.bo;

import cc.liyinghao.common.pojo.SysUser;
import lombok.Data;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;
import java.util.Date;
import java.util.List;

/**
 * SpringSecurity需要的UserDetails封装类
 */
@Data
public class SysUserDetails implements UserDetails {

    //用户
    private SysUser user;
    //拥有资源列表
    // private final List<UmsResource> resourceList;
    public SysUserDetails(SysUser user) {
        this.user = user;
    }

    //返回权限信息
    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return null;
    }

    @Override
    public String getPassword() {
        return user.getPassword();
    }

    @Override
    public String getUsername() {
        return user.getUsername();
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }

    public int getId() {
        return user.getId();
    }
    public String getHeadImgUrl() {
        return user.getHeadImgUrl();
    }
    public String getPhoneNumber() {
        return user.getPhoneNumber();
    }
    public Integer getStatus() {
        return user.getStatus();
    }
    public String getEmail() {
        return user.getEmail();
    }
    public String getNote() {
        return user.getNote();
    }
    public Date getCreateTime() {
        return user.getCreateTime();
    }
    public Date getLoginTime() {
        return user.getLoginTime();
    }
}
